﻿//    HexagonMine
//    Copyright (c) 2009-2010 BenBear
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.

#ifndef __HEXAGON_MINE_CONFIG_WINDOW_H__
#define __HEXAGON_MINE_CONFIG_WINDOW_H__

#pragma once

#include "HexagonMineGame.h"

#define MZ_IDC_HMC_TOOLBAR	101
#define MZ_IDC_HMC_SIZE		102
#define MZ_IDC_HMC_NUM_MINE	103
#define MZ_IDC_HMC_AUTO_LOCK_MINE	104
#define MZ_IDC_HMC_WIDTH			105
#define MZ_IDC_HMC_HEIGHT			106
#define MZ_IDC_HMC_RANDOM_SIZE		107
#define MZ_IDC_HMC_HEXAGON_SHAPE	108
#define MZ_IDC_HMC_MINE_DETECTOR	109
#define MZ_IDC_HMC_RIGHT_SIDE		110
#define MZ_IDC_HMC_MINE_PERCENT		111

class CHexagonMineConfigWnd :
	public CMzWndEx
{
  MZ_DECLARE_DYNAMIC(CHexagonMineConfigWnd);
public:
	CHexagonMineConfigWnd(hexagon_mine::CHexagonMineGame* game);
	~CHexagonMineConfigWnd();

private:
	hexagon_mine::CHexagonMineGame* m_Game;
	hexagon_mine::CHexagonMineGame::Config m_Config;

public:
	hexagon_mine::CHexagonMineGame::Config GetConfig() const
	{
		return m_Config;
	}

private:
	UiCaption m_Caption;
	
	UiToolbar_Text m_Toolbar;
	
	UiSingleLineEdit	m_About;

	UiStatic			m_AutoLockMineTitle;
	UiButtonEx			m_AutoLockMine;	// 自动锁定雷

	UiStatic			m_WidthTitle;
	UiStatusBar			m_Width;		// 宽度
	UiStatic			m_WidthNumber;
	bool				m_IsOriginalWidth;

	UiStatic			m_HeightTitle;
	UiStatusBar			m_Height;		// 高度
	UiStatic			m_HeightNumber;

	UiStatic			m_MinePercentTitle;
	UiStatusBar			m_MinePercent;	// 雷百分比
	UiStatic			m_MinePercentNumber;

	UiStatic			m_RandomSizeTitle;
	UiButtonEx			m_RandomSize;	// 随机宽高

	UiStatic			m_HexagonShapeTitle;
	UiButtonEx			m_HexagonShape;	// 六边形雷区

	UiStatic			m_MineDetectorTitle;
	UiButtonEx			m_MineDetector;	// 自动雷探测器

	UiStatic			m_RightSideTitle;
	UiButtonEx			m_RightSide;	// 是否扩展右侧

protected:
	// 窗口的初始化
	virtual BOOL OnInitDialog();
	// 重载 MZFC 的命令消息处理函数
	virtual void OnMzCommand(WPARAM wParam, LPARAM lParam);
	virtual LRESULT MzDefWndProc(UINT message, WPARAM wParam, LPARAM lParam);

private:
	void AddSwitch(int& y, UiStatic& title, UiButtonEx& button, bool on);
	void AddStatusBar(int& y, UiStatic& title, UiStatusBar& status, UiStatic& number);
	void UpdateStatusBar(UiStatusBar& status, UiStatic& number);

	void UpdateAutoLockMine();
	void UpdateRandomSize();
	void UpdateHexagonShape();
	void UpdateMineDetector();
	void UpdateRightSide();
	void SaveConfig();
};

#endif
